package view {
    import flash.utils.Dictionary;

    import mx.core.SoundAsset;

    [Bindable]
    public class SoundLocator {
        public static const SOUND_GET_EGG:String = "getEgg";
        public static const SOUND_TICK:String = "tick";
        public static const SOUND_SMASH_EGG:String = "smashEgg";
        public static const SOUND_JACKPOT:String = "jackpot";
        public static const SOUND_DROP_COIN:String = "dropCoin";

        [Embed(source='sounds/getEgg.mp3')]
        private static var getEgg:Class;
        [Embed(source='sounds/BleepWillow.mp3')]
        private static var tick:Class;
        [Embed(source='sounds/smashEgg.mp3')]
        private static var smashEgg:Class;
        [Embed(source='sounds/Jackpot.mp3')]
        private static var jackpot:Class;
        [Embed(source='sounds/DropCoin.mp3')]
        private static var dropCoin:Class;

        private static var _soundDict:Dictionary;

        public static function get soundDict():Dictionary {
            if (_soundDict == null) {
                _soundDict = new Dictionary();
                _soundDict[SOUND_GET_EGG] = new getEgg() as SoundAsset;
                _soundDict[SOUND_TICK] = new tick() as SoundAsset;
                _soundDict[SOUND_SMASH_EGG] = new smashEgg() as SoundAsset;
                _soundDict[SOUND_JACKPOT] = new jackpot() as SoundAsset;
                _soundDict[SOUND_DROP_COIN] = new dropCoin() as SoundAsset;
            }
            return _soundDict;
        }

        public static function playSound(soundName:String):void {
            if (Config.soundOn) {
                soundDict[soundName].play();
            }
        }
    }
}
